pengenalan
openshift => platform komputasi awan yang dikembangkan oleh Red Hat yang memungkinkan pengembang untuk membangun, menyebarkan, dan mengelola aplikasi secara lebih mudah dan efisien. cluster => Kubernetes
openshift cluster => oc
oc login -u <USERNAME> -p <PASSWORD> <API_ENDPOINT>:<PORT>
oc login -u user -p password https://api.ocp4.example.com:6443
oc whoami --show-console
1
oc login -u developer -p developer https://api.ocp4.example.com:6443
[student@workstation ~]$ oc whoami --show-console
https://console-openshift-console.apps.ocp4.example.com
open in browser
2
computes > nodes
click master01 > terminal
chroot /host
systemctl status kubeleet
systemctl status crio
review
Kubernetes and OpenShift Command-Line Interfaces and APIs
1
installasi cli
curl -LO "https://dl.k8s.io/release/$(curl -L \
-s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/$(curl -L \
-s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
[user@host ~]$ echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
kubectl: OK
- if error u can
sudo install -o root -g root -m 0755 kubectl \
/usr/local/bin/kubectl
- kubectl
kubectl version --client
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
[user@host ~]$ sudo yum install -y kubectl
kubectl --help
kubectl create --help
kubectl explain pod
oc
oc
oc login cluster-url
oc login --token=sha256-BW...rA8 \
--server=https://api.ocp4.example.com:6443
oc login https://api.ocp4.example.com:6443
Username: developer
Password: developer
Login successful.
oc new-project myapp
oc cluster-info #info
oc api-versions #version
oc get clusteroperator
oc get pod
oc get all
oc describe mysql-openshift-1-glgrp #deskripsi
oc explain pods.spec.containers.resources #menjelaskan submer api
oc create -f pod.yaml
oc status
oc status --sugest #identify issue
oc delete pod quotes-ui
oc get pods -n openshift-apiserver
2
kubernetes and openshift resources
oc api-resources
--namespaced=true Jika false, kembalikan sumber daya non-namespaced, jika tidak, kembalikan sumber daya namespaced
--api-group apps Batasi sumber daya dalam grup API yang ditentukan. Gunakan untuk menampilkan sumber daya inti.--api-group=''
--sort-by name Jika tidak kosong, urutkan daftar sumber daya menggunakan bidang tertentu. Bidang dapat berupa 'nama' atau 'jenis'.
oc api-resources --namespaced=true --api-group apps --sort-by name
NAME SHORTNAMES APIVERSION NAMESPACED KIND
controllerrevisions apps/v1 true ControllerRevision
daemonsets ds apps/v1 true DaemonSet
deployments deploy apps/v1 true Deployment
oc explain pod
oc explain pod.spec
oc get pod --selector group=developers
oc get pods -o wide #showing many key
[user@host ~]$ oc get pods -o yaml
apiVersion: v1
items:
- apiVersion: v1
kind: Pod
metadata:
annotations:
...object omitted...
[user@host ~]$ oc get pods -o yaml | yq r - 'items[0].status.podIP'
10.8.0.60
oc get pods -o json
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
oc get pods -o json | jq '.items[0].status.podIP'
"10.8.0.60"
oc get pods \
-o custom-columns=PodName:".metadata.name",\
ContainerName:"spec.containers[].name",\
Phase:"status.phase",\
IP:"status.podIP",\
Ports:"spec.containers[].ports[].containerPort"
PodName ContainerName Phase IP Ports
myapp-77fb5cd997-xplhz myapp Running 10.8.0.60 <none>
oc get pods \
-o jsonpath='{range .items[]}{"Pod Name: "}{.metadata.name}
{"Container Names:"}{.spec.containers[].name}
{"Phase: "}{.status.phase}
{"IP: "}{.status.podIP}
{"Ports: "}{.spec.containers[].ports[].containerPort}
{"Pod Start Time: "}{.status.startTime}{"\n"}{end}'
PodName ContainerName Phase IP Ports
myapp-77fb5cd997-xplhz myapp Running 10.8.0.60 <none>